#include <iostream>
#include <vector>
#include <algorithm> // std::for_each
#include <functional> // std::bind
using namespace std;
using namespace std::placeholders;

class MyClass {
private:
    int a;
public:
    MyClass(int a):a(a){}
    void print(void) const {
        cout << a << endl;
    }
};

int main() {
    vector<MyClass> vec = { MyClass(1), MyClass(2), MyClass(3), MyClass(4), MyClass(5)};
    MyClass myObject(10);

    // 使用std::bind将成员函数绑定到对象上，并将该绑定函数传递给std::for_each
//    for_each(vec.begin(), vec.end(), bind(&MyClass::print, _1));

    auto func = bind(&MyClass::print, myObject);
    func();

    return 0;
}

